package com.heima.behavior.controller.v1;

import com.heima.behavior.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "用户行为api",tags = "用户行为api")
@RestController
@RequestMapping("/api/v1")
public class AppBehaviorController {

    @Autowired
    private ApLikesBehaviorService apLikesBehaviorService;

    @ApiOperation("用户点赞或取消点赞")
    @PostMapping("/likes_behavior")
    public ResponseResult like(@RequestBody @Validated LikesBehaviorDTO dto){
        return apLikesBehaviorService.like(dto);
    }

    @Autowired
    private ApReadBehaviorService apReadBehaviorService;

    @ApiOperation("用户阅读")
    @PostMapping("/read_behavior")
    public ResponseResult readBehavior(@RequestBody ReadBehaviorDTO dto){
        return apReadBehaviorService.readBehavior(dto);
    }

    @Autowired
    private ApUnlikeBehaviorService apUnlikeBehaviorService;

    @ApiOperation("保存或取消 不喜欢行为")
    @PostMapping("/un_likes_behavior")
    public ResponseResult unlikeBehavior(@RequestBody @Validated UnLikesBehaviorDTO dto){
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }

    @Autowired
    private ApCollectionBehaviorService apCollectionBehaviorService;

    @ApiOperation("保存或取消 收藏行为")
    @PostMapping("/collection_behavior")
    public ResponseResult collectBehavior(@RequestBody @Validated CollectionBehaviorDTO dto){
        return apCollectionBehaviorService.collectBehavior(dto);
    }

    @Autowired
    private ApArticleBehaviorService apArticleBehaviorService;

    @ApiOperation("查询文章行为相关信息")
    @PostMapping("/article/load_article_behavior")
    public ResponseResult loadArticleBehavior(@RequestBody ArticleBehaviorDTO dto){
        return apArticleBehaviorService.loadArticleBehavior(dto);
    }

}
